//
//  HeroViewController.m
//  LOL_PalmarHelper
//
//  Created by dllo on 15/6/20.
//  Copyright (c) 2015年 hantao. All rights reserved.
//

#import "HeroViewController.h"

@interface HeroViewController ()

@end

@implementation HeroViewController


-(void)dealloc
{
    [_freeHero release];
    [_allHero release];
    [super dealloc];



}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    
    
    self.allHero = [[AllHeroViewController alloc] init];
    [self addChildViewController:self.allHero];
    [self.view addSubview:self.allHero.view];
    [_allHero release];
    
    self.freeHero = [[FreeHeroViewController alloc] init];
    [self addChildViewController:self.freeHero];
    [self.view addSubview:self.freeHero.view];
    [_freeHero release];
    
    [self setAutomaticallyAdjustsScrollViewInsets:NO];

    
    
    UISegmentedControl *segmentC = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"周免英雄",@"全部英雄", nil]];
    segmentC.backgroundColor = [UIColor groupTableViewBackgroundColor];
   

     segmentC.frame = CGRectMake(100, 30, 175, 30);
    segmentC.layer.masksToBounds = YES;
    segmentC.layer.cornerRadius = 5;
    segmentC.layer.borderColor = [UIColor whiteColor].CGColor;
    segmentC.layer.borderWidth = 1;
    

    [segmentC addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    
    segmentC.selectedSegmentIndex = 0;
    
    
    self.navigationItem.titleView = segmentC;
    
    
}





-(void)segmentAction:(UISegmentedControl *)segment
{

    if (segment.selectedSegmentIndex == 0) {
        
        [self.view bringSubviewToFront:self.freeHero.view];
        
    }

    if (segment.selectedSegmentIndex == 1) {
        
        [self.view bringSubviewToFront:self.allHero.view];
    }
    

}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
